﻿
@{
    ViewData["Title"] = "用户-角色关联";
    Layout = "~/Views/Shared/_ManageFormLayout.cshtml";
}

<form id="form1">
    <input type="hidden" id="UserId" name="UserId" value="" />
    <tree-collapse-toggle items="@ViewBag.Items" class="mdui-list" mdui-collapse></tree-collapse-toggle>
</form>

@section Scripts{
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

    <script>
        var userId = $.request('id');
        $(function () {
            $('#UserId').val(userId);
        });

        function submitForm() {
            if (!$("#form1").valid()) {
                return false;
            }
            var postData = $('#form1').formSerialize();

            var vals = $('input:checkbox[name="permission"]:checked').map(function (index, elem) {
                return $(elem).val();
            }).get().join(',');
            postData['permissions'] = vals;

            $.submitForm({
                url: "/SystemManage/User/RoleRelation",
                param: postData,
                success: function () {
                    $.currentWindow().location.reload();
                }
            });

        };
    </script>
}

